package com.ias.log.dto;

import java.util.Optional;

// import com.github.structlog4j.IToLog;
// import com.ias.common.auth.details.LoginAppUser;
// import com.ias.common.util.SysUserUtil;
// import com.ias.common.util.TokenUtil;
import com.ias.log.util.TraceUtil;

import lombok.Builder;
import lombok.Data;

/**
 * 业务日志
 * @author someday
 * @create 2020年04月02日
 * blog: https://blog.51cto.com/13005375 
 * code: https://gitee.com/owenwangwen/open-capacity-platform
 * 
 * 注意：此类依赖一些未实现的工具类，如果项目中没有对应的依赖，可以删除或注释此类
 * 依赖类：structlog4j.IToLog, LoginAppUser, SysUserUtil, TokenUtil
 */
@Data
@Builder
public class LogEntry /* implements IToLog */ {
   
    private String transId;
    private String path ;
    private String clazz ;
    private String method ;
    private String token ;
    private String username ;
    private String msg ;
    private String error ;
  
    
    // @Override
    public Object[] toLog() {
        return new Object[] {
                "transId",  Optional.ofNullable(TraceUtil.getTrace()).orElse(""),
                "path", Optional.ofNullable(path).orElse(""),
                "clazz", Optional.ofNullable(clazz).orElse(""),
                "method", Optional.ofNullable(method).orElse(""),
                "token", Optional.ofNullable(token).orElse(""),
                "username", Optional.ofNullable(username).orElse(""),
                "msg", Optional.ofNullable(msg).orElse(""),
                "error", Optional.ofNullable(error).orElse("")
        };
    }
}
